package nil.ed.lazy.net.utils;

import nil.ed.lazy.io.utils.StreamUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * @author lidelin
 * @since 1.0
 */
public class DownloadUtils {

    /**
     * download bytes from url
     * @param url any url supported by {@link java.net.URL}
     * @return bytes
     * @throws IOException any net io exp
     */
    public static byte[] download(String url) throws IOException {
        InputStream in = new URL( url).openConnection().getInputStream();
        return StreamUtils.copyToByteArray(in);
    }

}
